﻿/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
/**
 * 定义全局变量，立案机构ID
 **/ 
var organId,organName,departId,departName,xzqhId,xzqhName,userId,userName;
var onLine = navigator.onLine;
organId = $.cookie("organId");

organName = $.cookie("organName");

departId = $.cookie("departId");

departName = $.cookie("departName");

xzqhId = $.cookie("xzqhId");

xzqhName = $.cookie("xzqhName");

userId = $.cookie("userId");

userName = $.cookie("userName");
var app = {
    // Application Constructor
    initialize: function() {
        this.bindEvents();
    },
    // Bind Event Listeners
    //
    // Bind any events that are required on startup. Common events are:
    // 'load', 'deviceready', 'offline', and 'online'.
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    // deviceready Event Handler
    //
    // The scope of 'this' is the event. In order to call the 'receivedEvent'
    // function, we must explicitly call 'app.receivedEvent(...);'
    onDeviceReady: function() {
       // app.receivedEvent('deviceready');
    },
    // Update DOM on a Received Event
    receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

    }
};

if(onLine){
	/**
	 * 创建案件表
	 **/
	createPonCaseBasicInfo();
	
	/**
	 *  创建案件登记处理表
	 */
	createPonCaseBasicInfoCl();
	
}

// put all your jQuery goodness in here. 
//	app.initialize();

$(document).on("pageinit","#home_index",function(){
//	loginMoveOnLine("admin","12345678");
	
	if($.trim(organId).length > 0){
		findPDataVersionByIdOffLine();
	}

	/**
	 * 绑定案件登记事件
	 */
	$("#ajdj").on('click',function(){
		if($.trim(organId).length <= 0){
			$.mobile.changePage ('login.html', 'pop', false, false);
		}else{
			$.mobile.changePage ('caseregister/zfmlIndexInfo.html', 'pop', false, false);
		}
	});
	
	/**
	 * 绑定案件接入事件
	 */
	$("#ajjr").on('click',function(){
		if($.trim(organId).length <= 0){
			$.mobile.changePage ('login.html', 'pop', false, false);
		}else{
			$.mobile.changePage ('config/caseaccess.html', 'pop', false, false);
		}
	});
	
	/**
	 * 绑定黑名单事件
	 */
	$("#hmd").on('click',function(){
		if($.trim(organId).length <= 0){
			$.mobile.changePage ('login.html', 'pop', false, false);
		}else{
			$.mobile.changePage ('black/black.html', 'pop', false, false);
		}
	});
	
	/**
	 * 绑定证据采集事件
	 */
	$("#zjcj").on('click',function(){
		if($.trim(organId).length <= 0){
			$.mobile.changePage ('login.html', 'pop', false, false);
		}else{
			$.mobile.changePage ('evidencecollect/evidenceCollect.html', 'pop', false, false);
		}
	});
	
	/**
	 * 绑定案件中心事件
	 */
	$("#ajzx").on('click',function(){
		if($.trim(organId).length <= 0){
			$.mobile.changePage ('login.html', 'pop', false, false);
		}else{
			$.mobile.changePage ('index/caseCenter.html', 'pop', false, false);
		}
	});
	
	/**
	 * 绑定个人中心事件
	 */
	$("#grzx").on('click',function(){
		if($.trim(organId).length <= 0){
			$.mobile.changePage ('login.html', 'pop', false, false);
		}else{
			$.mobile.changePage ('index/personalCenter.html', 'pop', false, false);
		}
	});
	
	
	
	//先解绑，再绑定
	$('#testcordova').on("tap", function() { 
	//alert(navigator.askshake.jsInteract); 
		navigator.askshake.jsInteract('NDljY2E1ZGM4NzUzM2U3Yg==,order,5740');      
	});        
	//on直接绑定        
	$('#testcordova2').on("tap",function(){
		$('#testcordova2').hide();  
	});
	
});

$(function () {
	$('#home_slider').flexslider({
		animation : 'slide',
		controlNav : true,
		directionNav : true,
		animationLoop : true,
		slideshow : true,
		slideshowSpeed:5000,
		useCSS : false,
		touch:true
	});
});


/**
 * 设置缓存
 * @param data
 *//*
function setMoveCookie(data){
	*//**
	 * 用户Id
	 **//*
	$.cookie('userId',data.id,{expires : 7,path : '/'});
	*//**
	 * 用户名称
	 **//*
	$.cookie('userName',data.username,{expires : 7,path : '/'});
	*//**
	 * 机构ID
	 **//*
	$.cookie('organId',data.organId,{expires : 7,path : '/'});
	
	*//**
	 * 机构名称
	 **//*
	$.cookie('organName',data.organName,{expires : 7,path : '/'});
	
	*//**
	 * 行政区划ID
	 **//*
	$.cookie('xzqhId',data.xzqhId,{expires : 7,path : '/'});
	
	*//**
	 * 行政区划名称
	 **//*
	$.cookie('xzqhName',data.xzqhName,{expires : 7,path : '/'});
	
	*//**
	 * 部门ID
	 **//*
	$.cookie('departId',data.departId,{expires : 7,path : '/'});
	
	*//**
	 * 部门名称
	 **//*
	$.cookie('departName',data.departName,{expires : 7,path : '/'});
	
//	self.location.href = "index.html";
	organId = $.cookie("organId");

	organName = $.cookie("organName");

	departId = $.cookie("departId");

	departName = $.cookie("departName");

	xzqhId = $.cookie("xzqhId");

	xzqhName = $.cookie("xzqhName");

	userId = $.cookie("userId");

	userName = $.cookie("userName");
}
*/
